package test;


import org.NooLab.nativebrowser.*;
import org.NooLab.nativebrowser.components.WebBrowserPublicIntf;
import org.NooLab.utilities.logging.PrintLog;



/*
 * there is still a memory issue: each call consumes 1Mb which won't be released anymore...
 */


public class NooLabNativeBrowser_test {

	public static void main(String[] args) {

		new NNB(args);
	}
}



class NNB {
	
	WebBrowserPublicIntf browser ;
	String html;
	
	public NNB(String[] args){
	
		try {
		
			browser = WebBrowserPublic.open();

		} catch (Exception e1) {
			e1.printStackTrace();
		}
		
		try {
			multitest(10);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		browser.close();
	}

	private void multitest(int n) throws Exception {
		
		for (int i=0;i<n;i++){
			PrintLog.Print(2, "call no."+(i+1)) ;
			go(i);
			PrintLog.Delay(2000);
		}
		
	}
	
	private void go(int k) throws Exception{
		
		  browser = WebBrowserPublic.open();
		  // this will be re-routed to "browser.reset()" if the instance already exists
		
		  browser.showDebug(2);
		  
		  
		  if (k%2==0){
			  html = browser.navigate("www.google.com");
		  }else{
			  html = browser.navigate("www.bing.com");
		  }
		  

		  System.err.println( "\n\n....................................................\n\n"+html);
		  PrintLog.Print(1, "\n\n..................................................\n\n") ;

		  
		  // browser.close();

	}

	
	
	

}